/**
 * @author 陈泰来
 * @version V1.0
 * @Project echo-im-sdk
 * @Title 消息处理工具类
 * @Description *
 * @Package util
 * @date 2021/6/18 3:32 下午
 * @Copyright:学如逆水行舟，不进则退 .
 */
package com.echo.sdk.im.util;

import com.echo.sdk.im.model.CIMMsg;
import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import lombok.extern.slf4j.Slf4j;

import java.io.IOException;

@Slf4j
public final class MessageUtils {

    /**
     * @return com.ws.whdsj.config.websocket.entity.HttpMsg
     * @author chentl
     * @description 解析前端参数
     * @date 2019/3/19 9:36
     * @params [data]
     * @since JDK 1.7
     */
    public static CIMMsg convertMsg(String data) {
        ObjectMapper objectMapper = new ObjectMapper();
        CIMMsg cimMsg;
        try {
            cimMsg = objectMapper.readValue(data, new TypeReference<CIMMsg>() {
            });
        } catch (IOException e) {
            log.error("[server]websocket 消息格式错误", e);
            return null;
        }
        return cimMsg;
    }
}
